package scenetracer;

import java.awt.BorderLayout;
import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class Viewer  extends JPanel {

	static final long serialVersionUID = 0L;
	
	public Viewer(JFrame jFrame, BufferedImage image) {
		super();
		JLabel imageLabel = new JLabel();
		imageLabel.setIcon(new ImageIcon(image));
		this.add(imageLabel, BorderLayout.CENTER);
	}
	
	private static BufferedImage imageInput = null;
	
	public static void view(BufferedImage image) {
		imageInput = image;
		
		
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				JFrame jFrame = new JFrame();
				jFrame.setTitle("Scene Tracer");
				jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				jFrame.setContentPane(new Viewer(jFrame, imageInput));
				jFrame.pack();
				jFrame.setVisible(true);
			}
		});
	}
	
}